{% extends 'tasks/base.html' %}

{% block title %}更新个人资料{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0">更新个人资料</h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            <label for="{{ form.username.id_for_label }}" class="form-label">用户名</label>
                            {{ form.username.errors }}
                            <input type="text" name="{{ form.username.name }}" value="{{ form.username.value|default:'' }}" 
                                   class="form-control {% if form.username.errors %}is-invalid{% endif %}" 
                                   id="{{ form.username.id_for_label }}" required>
                            {% if form.username.help_text %}
                                <small class="form-text text-muted">{{ form.username.help_text }}</small>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.first_name.id_for_label }}" class="form-label">名字</label>
                            {{ form.first_name.errors }}
                            <input type="text" name="{{ form.first_name.name }}" value="{{ form.first_name.value|default:'' }}" 
                                   class="form-control {% if form.first_name.errors %}is-invalid{% endif %}" 
                                   id="{{ form.first_name.id_for_label }}">
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.last_name.id_for_label }}" class="form-label">姓氏</label>
                            {{ form.last_name.errors }}
                            <input type="text" name="{{ form.last_name.name }}" value="{{ form.last_name.value|default:'' }}" 
                                   class="form-control {% if form.last_name.errors %}is-invalid{% endif %}" 
                                   id="{{ form.last_name.id_for_label }}">
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.email.id_for_label }}" class="form-label">电子邮箱</label>
                            {{ form.email.errors }}
                            <input type="email" name="{{ form.email.name }}" value="{{ form.email.value|default:'' }}" 
                                   class="form-control {% if form.email.errors %}is-invalid{% endif %}" 
                                   id="{{ form.email.id_for_label }}">
                        </div>
                        
                        <div class="d-flex justify-content-between">
                            <a href="{% url 'user-center' %}" class="btn btn-secondary">返回</a>
                            <button type="submit" class="btn btn-primary">保存更改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}